<%@ page language="java" contentType="text/html; charset=UTF-8"
		 pageEncoding="UTF-8"%>
<%@include file="common/header.jsp"%>
<div class="clearfix"></div>
<div class="row">

	<div class="col-md-12">
		<div class="x_panel">
			<div class="x_title">
				<h2>
					APP 审核列表 <i class="fa fa-user"></i><small>${loginUser.devName}
					- 您可以通过搜索或者其他的筛选项对APP的信息进行审核操作。^_^</small>
				</h2>
				<div class="clearfix"></div>
			</div>
			<div class="x_content">
				<form method="post" action="/queryAllApp">
					<input type="hidden" name="pageNumer" value="1" />
					<input type="hidden" name="index" id="index" value="${pageResult.index}">
					<ul>
						<li>
							<div class="form-group">
								<label class="control-label col-md-3 col-sm-3 col-xs-12">软件名称</label>
								<div class="col-md-6 col-sm-6 col-xs-12">
									<input name="querySoftwareName" type="text" class="form-control col-md-7 col-xs-12" value="${pageResult.querySoftwareName}">
								</div>
							</div>
						</li>

						<li>
							<div class="form-group">
								<label class="control-label col-md-3 col-sm-3 col-xs-12">所属平台</label>
								<div class="col-md-6 col-sm-6 col-xs-12">
									<select id="queryFlatformId" name="checkFlat" class="form-control">
										<option value="">--请选择--</option>
									</select>
								</div>
							</div>
						</li>
						<li>
							<div class="form-group">
								<label class="control-label col-md-3 col-sm-3 col-xs-12">一级分类</label>
								<div class="col-md-6 col-sm-6 col-xs-12">
									<select id="queryCategoryLevel1" name="queryCategoryLevel1" class="form-control">
										<option value="">--请选择--</option>

									</select>
								</div>
							</div>
						</li>
						<li>
							<div class="form-group">
								<label class="control-label col-md-3 col-sm-3 col-xs-12">二级分类</label>
								<div class="col-md-6 col-sm-6 col-xs-12">
									<input type="hidden" name="categorylevel2list" id="categorylevel2list"/>
									<select name="queryCategoryLevel2" id="queryCategoryLevel2" class="form-control">
										<option value="">--请选择--</option>
									</select>
								</div>
							</div>
						</li>
						<li>
							<div class="form-group">
								<label class="control-label col-md-3 col-sm-3 col-xs-12">三级分类</label>
								<div class="col-md-6 col-sm-6 col-xs-12">
									<select name="queryCategoryLevel3" id="queryCategoryLevel3" class="form-control">
										<option value="">--请选择--</option>
									</select>
								</div>
							</div>
						</li>
						<li><button type="submit" class="btn btn-primary"> 查 &nbsp;&nbsp;&nbsp;&nbsp;询 </button></li>
					</ul>
				</form>
			</div>
		</div>
	</div>
	<div class="col-md-12 col-sm-12 col-xs-12">
		<div class="x_panel">
			<div class="x_content">
				<p class="text-muted font-13 m-b-30"></p>
				<div id="datatable-responsive_wrapper"
					 class="dataTables_wrapper form-inline dt-bootstrap no-footer">
					<div class="row">
						<div class="col-sm-12">
							<a  href="/info/appAdd?createdBy=${loginUser.createdBy}"><button>新增APP信息</button></a>
							<table id="datatable-responsive" class="table table-striped table-bordered dt-responsive nowrap dataTable no-footer dtr-inline collapsed"
								   cellspacing="0" width="100%" role="grid" aria-describedby="datatable-responsive_info" style="width: 100%;">
								<thead>
								<tr role="row">
									<th class="sorting_asc" tabindex="0"
										aria-controls="datatable-responsive" rowspan="1" colspan="1"
										style="width: 70px;" aria-label="First name: activate to sort column descending"
										aria-sort="ascending">软件名称</th>
									<th class="sorting" tabindex="0"
										aria-controls="datatable-responsive" rowspan="1" colspan="1"
										style="width: 10px;"
										aria-label="Last name: activate to sort column ascending">
										APK名称</th>
									<th class="sorting" tabindex="0"
										aria-controls="datatable-responsive" rowspan="1" colspan="1"
										style="width: 90px;"
										aria-label="Last name: activate to sort column ascending">
										软件大小(单位:M)</th>
									<th class="sorting" tabindex="0"
										aria-controls="datatable-responsive" rowspan="1" colspan="1"
										style="width: 50px;"
										aria-label="Last name: activate to sort column ascending">
										所属平台</th>
									<th class="sorting" tabindex="0"
										aria-controls="datatable-responsive" rowspan="1" colspan="1"
										style="width: 170px;"
										aria-label="Last name: activate to sort column ascending">
										所属分类(一级分类、二级分类、三级分类)</th>
									<th class="sorting" tabindex="0"
										aria-controls="datatable-responsive" rowspan="1" colspan="1"
										style="width: 30px;"
										aria-label="Last name: activate to sort column ascending">
										状态</th>
									<th class="sorting" tabindex="0"
										aria-controls="datatable-responsive" rowspan="1" colspan="1"
										style="width: 30px;"
										aria-label="Last name: activate to sort column ascending">
										下载次数</th>
									<th class="sorting" tabindex="0"
										aria-controls="datatable-responsive" rowspan="1" colspan="1"
										style="width: 64px;"
										aria-label="Last name: activate to sort column ascending">
										最新版本号</th>
									<th class="sorting" tabindex="0"
										aria-controls="datatable-responsive" rowspan="1" colspan="1"
										style="width: 30px;"
										aria-label="Last name: activate to sort column ascending">
										操作</th>
								</tr>
								</thead>
								<tbody>
								<c:forEach var="appInfo" items="${pageResult.queryallApp1}" varStatus="status">
									<tr role="row" class="odd">
										<td tabindex="0" class="sorting_1">${appInfo.softwareName}</td>
										<td>${appInfo.APKName }</td>
										<td>${appInfo.softwareSize }</td>
										<td>${appInfo.flatformName}</td>
										<td>${appInfo.categoryLevel1Name} -> ${appInfo.categoryLevel2Name } -> ${appInfo.categoryLevel3Name }</td>
										<td>${appInfo.statusName }</td>
										<td>${appInfo.downloads }</td>
										<td>${appInfo.versionNo }</td>
										<td>
											<div class="btn-group">
												<button type="button" class="btn btn-danger">点击操作</button>
												<button type="button" class="btn btn-danger dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
													<span class="caret"></span>
													<span class="sr-only">Toggle Dropdown</span>
												</button>
												<ul class="dropdown-menu" role="menu">
													<li>
														<c:choose>
															<c:when test="${appInfo.status == 2 || appInfo.status == 5}">
																<a class="saleSwichOpen" saleSwitch="open" appinfoid=${appInfo.id }  appsoftwarename=${appInfo.softwareName } data-toggle="tooltip" data-placement="top" title="" data-original-title="恭喜您，您的审核已经通过，您可以点击上架发布您的APP">上架</a>
															</c:when>
															<c:when test="${appInfo.status == 4}">
																<a class="saleSwichClose" saleSwitch="close" appinfoid=${appInfo.id }  appsoftwarename=${appInfo.softwareName } data-toggle="tooltip" data-placement="top" title="" data-original-title="您可以点击下架来停止发布您的APP，市场将不提供APP的下载">下架</a>
															</c:when>
														</c:choose>
													</li>
													<li><a class="addVersion" appinfoid="${appInfo.id }" data-toggle="tooltip" data-placement="top" title="" data-original-title="新增APP版本信息">新增版本</a>
													</li>
													<li><a class="modifyVersion"
														   appinfoid="${appInfo.id }" versionid="${appInfo.versionId }" status="${appInfo.status }"
														   statusname="${appInfo.statusName }"
														   data-toggle="tooltip" data-placement="top" title="" data-original-title="修改APP最新版本信息">修改版本</a>
													</li>
													<li><a  class="modifyAppInfo"
															appinfoid="${appInfo.id }" status="${appInfo.status }" statusname="${appInfo.statusName }"
															data-toggle="tooltip" data-placement="top" title="" data-original-title="修改APP基础信息">修改</a></li>
													<li><a  class="viewApp" appinfoid=${appInfo.id }  data-toggle="tooltip" data-placement="top" title="" data-original-title="查看APP基础信息以及全部版本信息">查看</a></li>
													<li><a  class="deleteApp" appinfoid=${appInfo.id }  appsoftwarename=${appInfo.softwareName } data-toggle="tooltip" data-placement="top" title="" data-original-title="删除APP基础信息以及全部版本信息">删除</a></li>
												</ul>
											</div>

										</td>
									</tr>
								</c:forEach>
								</tbody>
							</table>
						</div>
					</div>
					<div class="row">
						<div class="col-sm-5">
							<div class="dataTables_info" id="datatable-responsive_info"
								 role="status" aria-live="polite">共${pageResult.totalCount}条记录
								${pageResult.taotalPage}页，这是第${pageResult.pageNum}页</div>

						</div>
						<c:choose>
							<c:when test="${!empty pageResult.queryallApp1}">
								<div class="col-sm-7">
									<div class="dataTables_paginate paging_simple_numbers"
										 id="datatable-responsive_paginate">
										<ul class="pagination">
											<li class="paginate_button previous"><a
													href="javascript:skip(1)"
													aria-controls="datatable-responsive" data-dt-idx="0"
													tabindex="0">首页</a>
											</li>
											<li class="paginate_button "><a
													href="javascript:skip(${pageResult.pageNum-1>0?pageResult.pageNum-1:1})"
													aria-controls="datatable-responsive" data-dt-idx="1"
													tabindex="0">上一页</a>
											<li class="paginate_button "><a
													href="javascript:skip(${pageResult.pageNum+1>pageResult.taotalPage?pageResult.taotalPage:pageResult.pageNum+1});"
													aria-controls="datatable-responsive" data-dt-idx="1"
													tabindex="0">下一页</a>
											</li>
											<li class="paginate_button next"><a
													href="javascript:skip(${pageResult.taotalPage});"
													aria-controls="datatable-responsive" data-dt-idx="7"
													tabindex="0">最后一页</a>
											</li>
										</ul>
									</div>
								</div>
							</c:when>
						</c:choose>
					</div>
				</div>

			</div>
		</div>
	</div>
</div>
<%@include file="common/footer.jsp"%>
<script src="${pageContext.request.contextPath }/statics/localjs/rollpage.js"></script>

<script>
	$(function () {
		$.ajax({
			type:"post",dateType:"JSON",url:"/checkfloat",
			success:function (respondate) {
				$.each($.parseJSON(respondate),function (index,float) {
					$("#queryFlatformId").append("<option value='"+float.valueId+"'>"+float.valueName+"</option>")
				})
			}
		})
	});

	$(function () {
		$.ajax({
			type:"post",dateType:"JSON",url:"/checkLevel1",
			success:function (respondate) {
				$.each($.parseJSON(respondate),function (index,level1) {
					$("#queryCategoryLevel1").append("<option value='"+level1.id+"'>"+level1.categoryName+"</option>")
				})
			}
		})
	});


	$("#queryCategoryLevel1").change(function () {
		var level1Value= $("#queryCategoryLevel1").val();
		$("#queryCategoryLevel2").find("option").remove();
		$.ajax({
			type:"post",dateType:"JSON",url:"/checkLevel2?level1="+level1Value,
			success:function (respondate) {
				$.each($.parseJSON(respondate),function (index,lavel2) {
					$("#queryCategoryLevel2").append("<option value='"+lavel2.id+"'>"+lavel2.categoryName+"</option>")
				})
			}
		})
	});

	$("#queryCategoryLevel2").change(function () {
		var levelValue=$("#queryCategoryLevel2").val();
		$("#queryCategoryLevel3").find("option").remove();
		$.ajax({
			type:"post",dateType:"JSON",url:"/checkLevel3?level2="+levelValue,
			success:function (respondate) {
				$.each($.parseJSON(respondate),function (index,lavel3) {
					$("#queryCategoryLevel3").append("<option value='"+lavel3.id+"'>"+lavel3.categoryName+"</option>")
				})
			}
		})
	});

	function skip (num) {
		window.location.href="/queryAllApp?" +
				"querySoftwareName=${pageResult.querySoftwareName}&queryCategoryLevel2=${pageResult.queryCategoryLevel2}&queryCategoryLevel3=${pageResult.queryCategoryLevel3}&checkFlat=${pageResult.checkFlat}&queryCategoryLevel1=${pageResult.queryCategoryLevel1}&pageNumer="+num;
	};


	$(function () {
		var index=$("#index").val();
		if (index==6636){
			alert("该APP状态不允许审核，请修改后再审核。")
			$("#index").cleanData();
		}else {

		}
	})
</script>